from django.conf.urls import url
from .home import views as home_views
from .user import views as user_views
from .goods import sku_views, spu_views, spec_views, opt_views, img_views, channel_views, brand_views
from rest_framework_jwt.views import obtain_jwt_token
from .order import order_views
from .system import prems_views, groups_views, admin_views

urlpatterns = [
    # 登录相关
    url('^authorizations/$', obtain_jwt_token),
    # 首页相关
    url('^statistical/total_count/$', home_views.TotalCountView.as_view()),
    url('^statistical/day_increment/$', home_views.DayIncrementView.as_view()),
    url('^statistical/day_active/$', home_views.DayActiveView.as_view()),
    url('^statistical/day_orders/$', home_views.DayOrdersView.as_view()),
    url('^statistical/month_increment/$', home_views.MonthIncrementView.as_view()),
    url('^statistical/goods_day_views/$', home_views.GoodsDayVisitView.as_view()),
    # 用户相关
    url('^users/$', user_views.UserView.as_view()),
    # 商品相关SKU
    url('^goods/simple/$', sku_views.GoodsSimple.as_view()),
    url('^goods/(?P<pk>\d+)/specs/$', sku_views.GoodsSpecsView.as_view()),
    # 商品SPU
    url('^goods/brands/simple/$', spu_views.BrandsSimple.as_view()),
    url('^goods/images/$', spu_views.GoodsImagesView.as_view()),
    url('^goods/channel_types/$', channel_views.ChannelTypeView.as_view()),
    url('^goods/categories/$', channel_views.Categories.as_view()),
    # 系统相关
    url('^permission/content_types/$', prems_views.ContentTypeView.as_view()),
    url('permission/simple/$', groups_views.SimpleView.as_view())

]
from rest_framework.routers import DefaultRouter

df_route = DefaultRouter()
# 商品相关
df_route.register(prefix='skus/images', viewset=img_views.ImageViewSet, base_name='img')
df_route.register(prefix='skus', viewset=sku_views.SkusViewSet, base_name='skus')
df_route.register(prefix='goods/specs', viewset=spec_views.SpecsViewSet, base_name='spec')
df_route.register(prefix='goods/channels', viewset=channel_views.ChannelViewSet, base_name='channel')
df_route.register(prefix='goods/brands', viewset=brand_views.BrandViewSet, base_name='brand')
df_route.register(prefix='goods', viewset=spu_views.SPUViewSet, base_name='spu')
df_route.register(prefix='goods/channel/categories', viewset=spu_views.CategoriesViewSet, base_name='category')
df_route.register(prefix='specs/options', viewset=opt_views.OptionViewSet, base_name='opt')
df_route.register(prefix='orders', viewset=order_views.OrderViewSet, base_name='order')
df_route.register(prefix='permission/perms', viewset=prems_views.PremissionViewSet, base_name='perms')
df_route.register(prefix='permission/groups', viewset=groups_views.GroupViewSet, base_name='group')
df_route.register(prefix='permission/admins', viewset=admin_views.AdminViewSet, base_name='admin')
urlpatterns += df_route.urls
for i in urlpatterns:
    print(i)
